Move pandas and matplotlib to optional extras#2244
Merged
Conversation
Update setup.py to remove them from core dependencies. Add lazy imports with clear error messages in logger, monitor, and plotter. Move read_csv and read_json helpers to test files. Update documentation and changelog.
There was a problem hiding this comment.
Pull request overview
This PR reduces Stable-Baselines3’s core dependency footprint by moving pandas and matplotlib out of install_requires and into optional extras, while adding clearer runtime errors and updating docs/tests to reflect the new optional plotting/loading behavior.
Changes:
- Move
pandas/matplotlibfrom core dependencies to theextraextra insetup.py. - Add explicit, user-facing
ImportErrormessages when plotting/loading utilities are used without optional dependencies. - Update tests and documentation to reflect the new optional dependency model; bump version to
2.9.0a2.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
setup.py |
Removes pandas/matplotlib from core deps and adds them under extras_require["extra"]. |
stable_baselines3/common/results_plotter.py |
Wraps pandas/matplotlib imports with clearer ImportErrors for plotting. |
stable_baselines3/common/monitor.py |
Makes pandas a lazy import in load_results() and raises a clearer ImportError if missing. |
stable_baselines3/common/logger.py |
Removes hard dependency on matplotlib (type-only import) and drops read_csv/read_json helpers. |
tests/test_logger.py |
Moves CSV/JSON reader helpers into tests and adds tests for missing pandas/matplotlib. |
docs/guide/plotting.md |
Documents that plotting requires pandas and matplotlib (or stable-baselines3[extra]). |
docs/misc/changelog.md |
Adds breaking-change notes for optional deps and moved helpers (needs minor corrections). |
README.md |
Updates installation/extras description and minor wording/formatting fixes. |
stable_baselines3/version.txt |
Bumps version from 2.9.0a1 to 2.9.0a2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Reduce the number of dependencies.
TODO:
Motivation and Context
closes #680
Types of changes
Checklist
docs/misc/changelog.md) (required).make format(required)make check-codestyleandmake lint(required)make pytestandmake typeboth pass. (required)make doc(required)Note: You can run most of the checks using
make commit-checks.Note: we are using a maximum length of 127 characters per line